package models

import (
	"time"

	"github.com/astaxie/beego/orm"
)

type ChatRecord struct {
	Id          int       `orm:"column(id);auto"`
	From        string    `orm:"column(from);size(50);null"`
	To          string    `orm:"column(to);size(50);null"`
	Chattime    time.Time `orm:"column(chattime);type(datetime);null"`
	Content     string    `orm:"column(content);size(255);null"`
	ContentType string    `orm:"column(content_type);size(30);null"`
	Createtime  time.Time `orm:"column(createtime);type(timestamp);null;auto_now_add"`
}

func (t *ChatRecord) TableName() string {
	return "chat_record"
}

func init() {
	orm.RegisterModel(new(ChatRecord))
}

// AddChatRecode insert a new ChatRecode into database and returns
// last inserted Id on success.
func AddChatRecode(m *ChatRecord) (id int64, err error) {
	o := orm.NewOrm()
	id, err = o.Insert(m)
	return
}
